package com.example.uitest;

import java.io.IOException;

import Send.Join_Login;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

public class JoinActivity extends Activity implements OnClickListener {
	
	Send.Join_Login S_join;
	Receive.Member R_join;
	EditText id;
	EditText pass;
	EditText nick;

	AsyncTask_01 A;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_join);

		Button btn_ok = (Button) findViewById(R.id.join_btn_ok);
		btn_ok.setOnClickListener(this);

		id = (EditText) findViewById(R.id.join_et_id);
		pass = (EditText) findViewById(R.id.join_et_pw);
		nick = (EditText) findViewById(R.id.join_et_nick);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.join_btn_ok:
			S_join = new Join_Login(2, id.getText().toString(), pass.getText().toString(), nick.getText().toString());
			try {
				S_join.Set_Length();
				S_join.Assemble_Packet();
				A = new AsyncTask_01(this);
				A.execute(2);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			break;
		}
	}

	@Override
	public void onBackPressed() {
		Intent intent = new Intent(getBaseContext(), LoginActivity.class);
		startActivity(intent);
		finish();
	}
}
